package com.yangrong.newsservice.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yangrong.newsservice.entity.NewsEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 微鲸新闻列表
 *
 * @author yangrong
 * @email 455833224@qq.com
 * @date 2020-08-26 15:21:07
 */
@Mapper
public interface NewsDao extends BaseMapper<NewsEntity> {

    @Select("select distinct type from news_list")
    List<String> getListType();

    @Select("select * from news_list limit 0, 10")
    List<NewsEntity> getNewsList();

    @Select("select * from news_list where type = #{type} limit 0, 10")
    List<NewsEntity> getNewsListByType(String type);

    @Select("select count(1) from news_list where type = #{type}")
    Integer getAllNewsSizeWithType(String type);

    @Select("select count(1) from news_list")
    Integer getAllNewsSizeNoType();

    @Select("select * from news_list where type = #{type} limit #{start}, #{getSize}")
    List<NewsEntity> getMoreWithType(String type, Integer start, Integer getSize);

    @Select("select * from news_list limit #{start}, #{getSize}")
    List<NewsEntity> getMoreNoType(Integer start, Integer getSize);

}
